package Code.Day5_20240922.com.dx.day05;

import lombok.ToString;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * @ClassName MorningExam
 * @Description 0922晨考
 * @Author 12994
 * @Date 2024/9/22 10:03
 * @Version 1.0
 **/
public class MorningExam {
    public static void main(String[] args) {
//        int[] num = {1, 2, 3, 4, 5, 6, 7};
        String[] str = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"};

        Scanner input = new Scanner(System.in);
        for (int i = 0; true; ) {
            int thisNum = -1;
            System.out.print("请输入一个1-7之间的数字, 输入0退出程序: ");
            try {
                thisNum = input.nextInt();
            } catch (InputMismatchException e) {
//                e.printStackTrace();
                System.out.println("只能输入数字!");
                break;
            }
            if (thisNum == 0) {
                System.out.println("程序结束");
                break;
            }
            try {
                System.out.println(str[thisNum - 1]);
            } catch (ArrayIndexOutOfBoundsException e) {
                System.out.println("您输入的数字不合格，只能输入1-7之间的数字!");
            }
        }
    }
}
